
#include <string>
#include "String.hpp"

void test_string1()
{

    string s1("hello world!!!");

    s1.push_back('a');
    s1.push_back('a');
    s1.push_back('a');
    s1.push_back('a');
    s1.push_back('a');
    s1.push_back('a');

    cout << s1 << endl;
}

void test_string2()
{
    string s1;
    s1.push_back('!');
    s1.push_back('a');

    cout << s1 << endl;

    //string s;
    //for (int i = 0; i < 100; i ++ )
    //{
    //    s.push_back('a');
    //    cout << s.capacity() << endl;
    //    cout << s << endl;
    //}

    string s2("hello linux!!!");
    string::iterator it = s2.begin();
    while (it != s2.end())
    {
        cout << *it << ' ';
        ++ it;
    }
    cout << endl;

    s2.append("hello linux");
    cout << s2 << endl;
    s2.append(s1);
    cout << s2 << endl;
    s2.append(6, 'c');
    cout << endl;

    s2 += "6666666666666";
    cout << s2 << endl;

    for (size_t i = 0; i < s2.size(); i ++ )
    {
        cout << s2[i] << ' '; 
    }
    cout << endl;
}

int main()
{
    test_string1();
    test_string2();

    cout << endl << endl;

    try
    {
        my_string::test();
    }
    catch(const exception& e)
    {
        cout << e.what() << endl;
    }

    return 0;
}
